cmake_minimum_required(VERSION 3.14)
project(matlab_to_cpp)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# --- 阶段1: 全局设置与包查找 ---
include_directories(include)
find_package(Threads REQUIRED)
find_package(OpenMP REQUIRED)

# --- 阶段2: 定义可执行文件目标 ---
add_executable(matlab_to_cpp 
    src/main_multi_cases.cpp
    src/CacheManager.cpp
    src/CoreLogic.cpp
    src/FileIO.cpp
    src/Optimizer.cpp
    src/VisualizationExporter.cpp
)

# --- 阶段3: 对已定义的目标进行配置 ---
# 所有 target_* 命令都必须在 add_executable 之后

# 为目标链接库
target_link_libraries(matlab_to_cpp PRIVATE Threads::Threads)
if(OpenMP_FOUND)
    message(STATUS "OpenMP found, enabling parallel support.")
    target_link_libraries(matlab_to_cpp PRIVATE OpenMP::OpenMP_CXX)
endif()

# 为目标添加编译宏定义
target_compile_definitions(matlab_to_cpp PRIVATE DATA_DIR="${CMAKE_SOURCE_DIR}/data")